const express = require('express')
const router = express.Router();
const db = require('../../utils/db')

module.exports = router
    //查询所有支付
router.get('/getpay', function(req, res, next) {
        let mysql = `SELECT* FROM pay_method`
        db(mysql, null, function(err, data) {
            if (err) {
                return res.json({
                    code: 500,
                    msg: '查询支付订单失败'
                })
            }
            res.json({
                code: 200,
                msg: "查询订单成功",
                data: data
            })
        })
    })
    // 删除某条数据
router.post('/deldata', function(req, res, ) {
    let mysql = `DELETE FROM pay_method WHERE pay_id=?`
    db(mysql, [req.body.pay_id], function(err, data) {
        console.log(err);
        if (err) {
            return res.json({
                code: 500,
                msg: '删除订单失败，请稍后重试'
            })
        }
        res.json({
            code: 200,
            msg: '删除该条数据成功',
            data: data
        })
    })
})